# coding=utf-8
from flask import request, jsonify, g
from app import route_api
from app.controller.BaseControllerHelper import *
from app.service.api.user import *
page_name = "user"


@route_api.my_route(page_name, "/login", methods=["POST"])
def login():
    data = request.json
    token = request.headers.get("token")
    token = token if token else ""
    email = get_values_by_request(data, "email")
    password = get_values_by_request(data, "password")
    # deviced_id =  get_values_by_request(data, "deviced_id")
    result = login_service(email, password, token)
    return jsonify(result)


@route_api.my_route(page_name, "/allinfo", methods=["POST"])
def user_all_info():
    token = request.headers.get("token")
    token = token if token else ""
    result = all_info_service(token)
    return jsonify(result)
